package com.ruoyi.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.domain.NewEnergyReport;
import com.ruoyi.mes.service.INewEnergyReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源合规报Controller
 * 
 * @author ruoyi
 * @date 2025-05-14
 */
@RestController
@RequestMapping("/mes/energyReport")
public class NewEnergyReportController extends BaseController
{
    @Autowired
    private INewEnergyReportService newEnergyReportService;

    /**
     * 查询能源合规报列表
     */
    @PreAuthorize("@ss.hasPermi('mes:energyReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(NewEnergyReport newEnergyReport)
    {
        startPage();
        List<NewEnergyReport> list = newEnergyReportService.selectNewEnergyReportList(newEnergyReport);
        return getDataTable(list);
    }

    /**
     * 导出能源合规报列表
     */
    @PreAuthorize("@ss.hasPermi('mes:energyReport:export')")
    @Log(title = "能源合规报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NewEnergyReport newEnergyReport)
    {
        List<NewEnergyReport> list = newEnergyReportService.selectNewEnergyReportList(newEnergyReport);
        ExcelUtil<NewEnergyReport> util = new ExcelUtil<NewEnergyReport>(NewEnergyReport.class);
        util.exportExcel(response, list, "能源合规报数据");
    }

    /**
     * 获取能源合规报详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:energyReport:query')")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return success(newEnergyReportService.selectNewEnergyReportByReportId(reportId));
    }

    /**
     * 新增能源合规报
     */
    @PreAuthorize("@ss.hasPermi('mes:energyReport:add')")
    @Log(title = "能源合规报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NewEnergyReport newEnergyReport)
    {
        return toAjax(newEnergyReportService.insertNewEnergyReport(newEnergyReport));
    }

    /**
     * 修改能源合规报
     */
    @PreAuthorize("@ss.hasPermi('mes:energyReport:edit')")
    @Log(title = "能源合规报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NewEnergyReport newEnergyReport)
    {
        return toAjax(newEnergyReportService.updateNewEnergyReport(newEnergyReport));
    }

    /**
     * 删除能源合规报
     */
    @PreAuthorize("@ss.hasPermi('mes:energyReport:remove')")
    @Log(title = "能源合规报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(newEnergyReportService.deleteNewEnergyReportByReportIds(reportIds));
    }
}
